﻿@{
    Layout = "~/Views/Shared/_DialogLayout.cshtml";
}

<div class="dialog-content">
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })

    <div data-autosize="true">
        <table id="datagrid"></table>
    </div>
</div>
<div class="dialog-footer">
    <button id="btnclose" class="btn btn-default">关闭</button>
    <button id="btnok" class="btn btn-primary">确定</button>
</div>

@section scripts{
    <script type="text/javascript">
        //回调函数
        var callback = "@Request.QueryString["callback"]";
        //列定义
        var cols = [[
         { field: "Id", title: 'Id', width: 10, hidden: true },
         { field: "ck", title: '', width: 20, checkbox: true },
         { field: "EvaluateYear", title: "测评年度", sortable: true, width: 100, align: 'center' },
         { field: "EvaluateStart", title: "开始日期", sortable: true, width: 100, align: 'center' },
         { field: "EvaluateEnd", title: "结束日期", sortable: true, width: 100, align: 'center' },
         { field: "Status", title: "状态", sortable: true, width: 100, align: 'center' }
        ]];

        $(document).ready(function () {
            //关闭
            $("#btnclose").click(function (evt) { evt.preventDefault(); parent.closeDialog(); return false; });
            //保存
            $("#btnok").click(function (evt) {
                evt.preventDefault();
                var jsondata = [];

                var selectedRows = $("#datagrid").datagrid("getSelections");

                if(selectedRows.length==0){
                    alert("请选择要查看的测评年度！");
                    return;
                }
                parent.eval(callback + "('" + JSON.stringify(selectedRows[0]) + "')");
                parent.closeDialog();
            });
            //查询
            $("#btnquery").click(function (evt) {
                evt.preventDefault();
                var params = $("#datagrid").datagrid('options').queryParams;
                params.typecode=typecode;
                params.s = $("#searchkey").val();
                $("#datagrid").datagrid("load");
                $("#datagrid").datagrid("clearSelections");
            });

            $("#searchkey").keydown(function (event) {
                if (event.keyCode == $.ui.keyCode.ENTER) {
                    event.preventDefault();
                    $("#btnquery").click();
                    return false;
                }
            });

            LoadDatagrid();
        });

        //加载列表数据
        function LoadDatagrid() {
            var $dg = $("#datagrid");
            $dg.datagrid({
                //title: '子项目字典',
                url: baseurl + 'Public/EvalListJson',
                fit: true,
                fitColumns: false,
                striped: true,
                nowrap: true,
                idField: 'Id',
                pagination: true,
                pageNumber: 1,
                pageSize: 100,
                pageList: [10, 20, 30, 50, 80, 100],
                rownumbers: true,
                singleSelect: true,
                queryParams: { },
                sortName: 'EvaluateYear',
                sortOrder: 'desc',
                columns: cols,
                onLoadSuccess: function () {
                    //多选时，加载完成后清除所有选中项（不然可能会有残留选中项）
                    //$dg.datagrid("clearSelections");
                },
                onDblClickRow: function (rowIndex, row) {
                    $("#btnok").click();
                }
            });
            //PaginationInit();
        }
    </script>
}











